// $Header: $
// Copyright (c) CODE Consulting and Development, s.r.o., Plzen. All rights reserved.
using System;
using System.Windows.Forms;
using OpcLabs.EasyOpc.DataAccess;
using OpcLabs.EasyOpc.OperationModel;
namespace ValueToMessageBox
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
// Create EasyOPC-DA component
var client = new EasyDAClient();
// Read item value and display it in a message box
try
{
object value = client.ReadItemValue("", "OPCLabs.KitServer.2", "Demo.Single");
MessageBox.Show(value?.ToString());
}
catch (OpcException opcException)
{
MessageBox.Show($"*** {opcException.Message}");
}
}
}
}
' $Header: $
' Copyright (c) CODE Consulting and Development, s.r.o., Plzen. All rights reserved.
Imports OpcLabs.EasyOpc.DataAccess
Imports OpcLabs.EasyOpc.OperationModel
Public Class Form1
' ReSharper disable InconsistentNaming
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As EventArgs) Handles Button1.Click
' ReSharper restore InconsistentNaming
' Create EasyOPC-DA component
Dim easyDaClient As New OpcLabs.EasyOpc.DataAccess.EasyDAClient
' Read item value and display it in a message box
Try
MessageBox.Show(easyDaClient.ReadItemValue("", "OPCLabs.KitServer.2", "Demo.Single"))
Catch opcException As OpcException
MessageBox.Show($"*** {opcException.Message}")
End Try
End Sub
End Class